patch -d qtbase -p1 -i $SRC/qmake-cflags.patch
patch -d qtbase -p1 -i $SRC/qmake-config.patch
patch -d qtscript  -p1 < $SRC/qt5-javascript-jit.patch


patch -p1 -i /sources/qt-everywhere-opensource-src-$surum-kf5-1.patch
patch -d qtbase -p1 -i $SRC/qtbase-everywhere-src-5.14.2-no_relocatable.patch
patch -d qtbase -p1 -i $SRC/qtbase-everywhere-src-5.15.2-libglvnd.patch
patch -d qtbase -p1 -i $SRC/qtbase-use-wayland-on-gnome.patch
patch -d qtbase -p1 -i $SRC/qtbase-5.15.8-fix-missing-qtsan-include.patch


export PYTHON='/usr/bin/python3'
mkdir $SRC/bin
ln -s /usr/bin/python3 $SRC/bin/python
export PATH="$SRC/bin:$PATH"

export QTDIR="$PWD"
export LD_LIBRARY_PATH="$QTDIR/qtbase/lib:$QTDIR/qttools/lib:$LD_LIBRARY_PATH"
export QT_PLUGIN_PATH="$QTDIR/qtbase/plugins"

./configure -prefix /usr \
        -archdatadir /usr/lib/qt \
        -bindir /usr/lib/qt/bin \
        -plugindir /usr/lib/qt/plugins \
        -importdir /usr/lib/qt/imports \
        -datadir /usr/share/qt \
        -docdir /usr/share/doc/qt \
        -translationdir /usr/share/qt/translations \
        -examplesdir /usr/share/doc/qt/examples \
        -headerdir /usr/include/qt \
        -libdir /usr/lib \
        -sysconfdir /etc/xdg \
        QMAKE_CFLAGS_RELEASE="$CFLAGS -Wno-enum-constexpr-conversion" \
		QMAKE_CXXFLAGS_RELEASE="$CXXFLAGS -Wno-enum-constexpr-conversion" \
		QMAKE_LFLAGS_RELEASE="${LDFLAGS} -fuse-ld=gold" \
        -confirm-license \
        -dbus-linked \
        -nomake examples \
        -no-pch \
        -no-rpath \
        -no-strip \
        -opengl desktop \
        -opensource \
        -openssl-linked \
        -optimized-qmake \
        -reduce-relocations \
        -release \
        -shared \
        -plugin-sql-{psql,mysql,sqlite,odbc} \
        -system-sqlite \
        -system-harfbuzz \
        -skip qtwebengine \
        -no-separate-debug-info \
        -silent -ccache

make $MAKEJOBS
